package com.burstly.lib.ui;

import android.util.AttributeSet;
import com.burstly.lib.util.LoggerExt;
import com.burstly.lib.util.Utils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public final class BurstlyViewConfigurator
{
  private static final String BURSTLY_SCHEME = "http://burstly.com/lib/ui/schema";
  private static final String BURSTLY_VIEW_ID = "burstlyViewId";
  private static final String CR_PARAMS = "crParams";
  private static final String DEFAULT_SESSION_LIFE = "defaultSessionLife";
  private static final LoggerExt LOG = LoggerExt.getInstance();
  private static final String MAX_AD_SIZE = "maxAdSize";
  private static final Pattern MAX_AD_SIZE_PATTERN = Pattern.compile("[0-9]+x[0-9]+");
  private static final String PUBLISHER_ID = "publisherId";
  private static final Pattern PUBLISHER_ID_PATTERN = Pattern.compile("[\\w-]{22}");
  private static final String PUB_TARGETING_PARAMS = "pubTargetingParams";
  private static final String TAG = "BurstlyViewConfigurator";
  private static final String USE_CACHED_RESPONSE = "useCachedResponse";
  private static final String ZONE_ID = "zoneId";
  private static final Pattern ZONE_ID_PATTERN = Pattern.compile("[\\d]{19}");
  private AttributeSet mAttributes;
  private final BurstlyView mBurstlyView;

  BurstlyViewConfigurator(BurstlyView paramBurstlyView)
  {
    this.mBurstlyView = paramBurstlyView;
  }

  private void extractAndApplyBurstlyViewId()
  {
    String str = this.mAttributes.getAttributeValue("http://burstly.com/lib/ui/schema", "burstlyViewId");
    if (str != null)
    {
      LOG.logDebug("BurstlyViewConfigurator", "Setting burstly view id to: {0}", new Object[] { str });
      this.mBurstlyView.setBurstlyViewId(str);
    }
  }

  private void extractAndApplyCrParams()
  {
    String str = this.mAttributes.getAttributeValue("http://burstly.com/lib/ui/schema", "crParams");
    if (str != null)
    {
      LOG.logDebug("BurstlyViewConfigurator", "Setting CR params to: {0}", new Object[] { str });
      this.mBurstlyView.setCrParms(str);
    }
  }

  private void extractAndApplyDefaultSessionLife()
  {
    Integer localInteger = Integer.valueOf(this.mAttributes.getAttributeIntValue("http://burstly.com/lib/ui/schema", "defaultSessionLife", -1));
    if (localInteger.intValue() != -1)
    {
      LOG.logDebug("BurstlyViewConfigurator", "Setting default session life to: {0}", new Object[] { localInteger });
      this.mBurstlyView.setDefaultSessionLife(localInteger.intValue());
    }
  }

  private void extractAndApplyMaxAdSize()
  {
    String str = this.mAttributes.getAttributeValue("http://burstly.com/lib/ui/schema", "maxAdSize");
    if (str != null)
    {
      if (!verifyAdMaxSizeString(str))
        break label146;
      LOG.logDebug("BurstlyViewConfigurator", "Setting max ad size to: {0}", new Object[] { str });
      String[] arrayOfString = str.split("x");
      int i = Utils.getIntValue(arrayOfString[0], Integer.valueOf(-1)).intValue();
      int j = Utils.getIntValue(arrayOfString[1], Integer.valueOf(-1)).intValue();
      if ((i > 0) && (j > 0))
        this.mBurstlyView.setMaxAdSize(i, j);
    }
    else
    {
      return;
    }
    LoggerExt localLoggerExt2 = LOG;
    Object[] arrayOfObject2 = new Object[2];
    arrayOfObject2[0] = this.mBurstlyView.getBurstlyViewId();
    arrayOfObject2[1] = str;
    localLoggerExt2.logInfo("BurstlyViewConfigurator", "BurstlyView: ''{0}'', maxAdSize ''{1}'', Zero or negative sized max size omitted.", arrayOfObject2);
    return;
    label146: LoggerExt localLoggerExt1 = LOG;
    Object[] arrayOfObject1 = new Object[2];
    arrayOfObject1[0] = this.mBurstlyView.getBurstlyViewId();
    arrayOfObject1[1] = str;
    localLoggerExt1.logError("BurstlyViewConfigurator", "BurstlyView: ''{0}'', maxAdSize ''{1}'', provided in xml layout is incorrect and omitted. Should be WIDTHxHEIGHT in dp.", arrayOfObject1);
  }

  private void extractAndApplyPubTargetingParams()
  {
    String str = this.mAttributes.getAttributeValue("http://burstly.com/lib/ui/schema", "pubTargetingParams");
    if (str != null)
    {
      LOG.logDebug("BurstlyViewConfigurator", "Setting pub targeting to: {0}", new Object[] { str });
      this.mBurstlyView.setPubTargetingParams(str);
    }
  }

  private void extractAndApplyPublisherId()
  {
    String str = this.mAttributes.getAttributeValue("http://burstly.com/lib/ui/schema", "publisherId");
    if (str != null)
    {
      if (verifyPublisherIdString(str))
      {
        LOG.logDebug("BurstlyViewConfigurator", "Setting pub id to: {0}", new Object[] { str });
        this.mBurstlyView.setPublisherId(str);
      }
    }
    else
      return;
    LoggerExt localLoggerExt = LOG;
    Object[] arrayOfObject = new Object[2];
    arrayOfObject[0] = this.mBurstlyView.getBurstlyViewId();
    arrayOfObject[1] = str;
    localLoggerExt.logError("BurstlyViewConfigurator", "BurstlyView: ''{0}'', publisher id ''{1}'', provided in xml layout is incorrect and omitted. Should be 22 long with alphanumeric and ''-'' and ''_''.", arrayOfObject);
  }

  private void extractAndApplyUseCachedResponse()
  {
    boolean bool = this.mAttributes.getAttributeBooleanValue("http://burstly.com/lib/ui/schema", "useCachedResponse", false);
    LoggerExt localLoggerExt = LOG;
    Object[] arrayOfObject = new Object[1];
    arrayOfObject[0] = Boolean.valueOf(bool);
    localLoggerExt.logDebug("BurstlyViewConfigurator", "Setting use cached response to: {0}", arrayOfObject);
    this.mBurstlyView.setUseCachedResponse(bool);
  }

  private void extractAndApplyZoneId()
  {
    String str = this.mAttributes.getAttributeValue("http://burstly.com/lib/ui/schema", "zoneId");
    if (str != null)
    {
      if (verifyZoneIdString(str))
      {
        LOG.logDebug("BurstlyViewConfigurator", "Setting zone id to: {0}", new Object[] { str });
        this.mBurstlyView.setZoneId(str);
      }
    }
    else
      return;
    LoggerExt localLoggerExt = LOG;
    Object[] arrayOfObject = new Object[2];
    arrayOfObject[0] = this.mBurstlyView.getBurstlyViewId();
    arrayOfObject[1] = str;
    localLoggerExt.logError("BurstlyViewConfigurator", "BurstlyView: ''{0}'', zone id ''{1}'', provided in xml layout is incorrect and omitted. Should be 19 long all digits.", arrayOfObject);
  }

  private static boolean matches(Pattern paramPattern, String paramString)
  {
    return paramPattern.matcher(paramString).matches();
  }

  private static boolean verifyAdMaxSizeString(String paramString)
  {
    return matches(MAX_AD_SIZE_PATTERN, paramString);
  }

  public static boolean verifyPublisherIdString(String paramString)
  {
    return matches(PUBLISHER_ID_PATTERN, paramString);
  }

  public static boolean verifyZoneIdString(String paramString)
  {
    return matches(ZONE_ID_PATTERN, paramString);
  }

  void configure(AttributeSet paramAttributeSet)
  {
    if (paramAttributeSet == null)
      return;
    this.mAttributes = paramAttributeSet;
    extractAndApplyBurstlyViewId();
    extractAndApplyCrParams();
    extractAndApplyDefaultSessionLife();
    extractAndApplyPublisherId();
    extractAndApplyPubTargetingParams();
    extractAndApplyUseCachedResponse();
    extractAndApplyZoneId();
    extractAndApplyMaxAdSize();
    this.mAttributes = null;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.ui.BurstlyViewConfigurator
 * JD-Core Version:    0.6.2
 */